package edu.uow.devdocs
/**
 * The Assignment entity.
 *
 * @author    
 *
 *
 */
class Assignment {
    static mapping = {
         table 'ASSIGNMENT'
         // version is set to false, because this isn't available by default for legacy databases
         version false
         id column:'ASSIGNMENT_ID'
         status column:'STATUS_ID'
         person column:'PERSON_ID'
         meetingMinutes column:'MEETING_MINUTES_ID'
         issue column:'ISSUE_ID'
         downtimeReport column:'DOWNTIME_REPORT_ID'
         developmentTask column:'DEVELOPMENT_TASK_ID'
         deployment column:'DEPLOYMENT_ID'
		 developmentChecklist column:'DEVELOPMENT_CHECKLIST_ID'
		 id generator: 'sequence', params:[sequence:'ASSIGNMENT_SEQ']
    }
    java.math.BigDecimal approvalFlag
    java.math.BigDecimal approved
    String assignmentComment
    Date requiredByDate
    Date lastUpdated
    // Relation
    AssignmentStatus status
    // Relation
    Person person
    // Relation
    MeetingMinutes meetingMinutes
    // Relation
    Issue issue
    // Relation
    DowntimeReport downtimeReport
    // Relation
    DevelopmentTask developmentTask
    // Relation
    Deployment deployment
	DevelopmentChecklist developmentChecklist
	Project project

    static constraints = {
        approvalFlag(nullable: true, size: 0..22)
        approved(nullable: true, size: 0..22)
        assignmentComment(nullable: true, size: 0..1024)
        requiredByDate(nullable: true)
        lastUpdated(nullable: true)
        status(nullable: true)
        person(nullable: true)
        meetingMinutes(nullable: true)
        issue(nullable: true)
        downtimeReport(nullable: true)
        developmentTask(nullable: true)
		developmentChecklist(nullable: true)
        deployment(nullable: true)
    }
	
    String toString() {
        return "${id} ${project} ${person}" 
    }
	
	Project getProject() {
		if (developmentChecklist?.project) return developmentChecklist?.project;
		if (developmentTask?.project) return developmentTask?.project;
		if (issue?.project) return issue?.project
		if (downtimeReport?.project) return downtimeReport?.project
		if (meetingMinutes?.project) return meetingMinutes?.project
	}
	
	
}
